The technology described herein relates to graphics processing systems and in particular to methods of and apparatus for identifying primitives and vertices to be rendered when rendering an output in a graphics processing system.
Computer graphics systems typically produce their output, such as frames for display, by processing so-called primitives, which are usually simple polygons such as triangles. Each primitive is normally defined by a set of vertices (e.g. 3 vertices in the case of a triangular primitive).
Typically the set of vertices to be used for a given graphics processing output (e.g. frame for display, draw call, etc.) will be stored as a set of vertex data defining the vertices (e.g. the relevant attributes for each of the vertices). A set of vertex data defining the vertices to be used for generating a given graphics processing output is typically referred to as a vertex buffer or vertex buffer stream.
While it would be possible simply to store the vertices to be used for each primitive to be generated in turn in the vertex buffer (such that, in effect, the list of vertices in the vertex buffer will correspondingly define the primitives to be processed), it is also known to define the primitives separately, in terms of a set of indices that reference the vertices in the set of vertex data. This can then avoid, e.g., the need to duplicate vertices in the set of vertex data (in the vertex buffer), as a single vertex entry in the vertex buffer can be referred to multiple times by reusing the relevant index in the set of indices.
In this case therefore the set of primitives to be processed for a given graphics processing output will be defined by a set of indices (an index buffer stream) that indicates the corresponding vertices in a set of vertex data (in a vertex buffer stream) that are to be used for the primitives in question. Again, the set of indices that refer to the vertices and define the primitives to be processed is typically referred to as an index buffer or an index buffer stream.
For example, for a set of vertices (a vertex buffer stream) V:
V=(A, B, C, D),
a set of indices (an index buffer stream) I:
I=(0, 1, 2, 3, 2, 1)
can be used to create the following set (in this case a pair) of triangular primitives P from the set of vertices (vertex buffer stream) V:
P=((A, B, C) (D, C, B))
In this example, the set of indices specifies each vertex to be used explicitly. However, it is also known to use more compact index representations in the set of indices for defining primitives to be processed. For example, a set of indices may define a triangle strip, in which the last two indices of the previous primitive are used for the next primitive. This then means that only one extra index is required to create a new (adjacent) triangular primitive. In these arrangements, the winding order of the primitives is typically also defined to change for each new primitive (e.g. such that if the current primitive count (or position) in the set of indices is odd, then the order of the first two indices in the primitive are swapped).
For example:
for
V=(A, B, C, D, E, F) and
I=(0, 1, 2, 3, 4, 5),
then
P=((A, B, C) (C, B, D) (C, D, E) (E, D, F))
With this scheme, since two out of every three indices are shared, a factor of three compaction for the set of indices can be achieved.
Corresponding arrangements are known and used for other primitive “types”, such as triangle fans, line strips, line loops, etc.
It is also known to include in a set of indices defining a set of primitives to be processed, one or more “primitive restarts”. A primitive restart is a position in the set of indices after which a new sequence of primitives, for example for a new triangle strip, is started. The next index (position) after a primitive restart is the start of a new primitive (irrespective of how the preceding sequence of indices in the set divides into primitives).
A primitive restart may be indicated, e.g., by way of a particular, optionally predefined, index value in the set of indices, that is to be interpreted as indicating that the next index position in the set of indices starts a new primitive.
The primitive restart feature allows a set of indices to be divided (at any desired point) into different sequences of primitives, e.g. where vertices between a pair of consecutive primitives in the set of indices are not shared. This is a useful technique for, e.g. combining multiple independent triangle strips together.
However, while the use of primitive restarts in a set of indices can be useful, it can lead to difficulties when using the set of indices to identify and generate primitives to be processed. For example, certain graphics processing operations may require “complete” primitives as their input.
However, as primitive restarts (when used) can occur anywhere in an input set of indices, the use of primitive restarts can make the identification of complete primitives in a set of indices that contains primitive restarts more difficult. For example, it may be necessary to analyse each primitive in the set of indices before a “current” primitive that is being considered, in order to be able to identify the correct set of vertices for the “complete” current primitive.
The Applicants accordingly believe that improved methods for handling sets of indices that may contain primitive restarts in graphics processing systems would be desirable.
Like reference numerals are used for like components where appropriate in the drawings.